package com.ds.lens.data.common.constant;

import lombok.Getter;

public enum MonitorStateEnum {
    NO_DATA(-1, 1, 1, "数据缺失"),
    OK(0, 2, 0, "正常"),
    ALARM_LEVEL_1(1, 7, 1, "一级"),
    ALARM_LEVEL_2(2, 6, 2, "二级"),
    ALARM_LEVEL_3(3, 5, 3, "三级"),
    ALARM_LEVEL_4(4, 4, 4, "四级"),
    ALARM_LEVEL_5(5, 3, 5, "五级");

    @Getter
    private int state; //lens状态

    @Getter
    private int level; //告警级别数字越大越高

    @Getter
    private int severity; //onduty 状态

    @Getter
    private String desc;

    MonitorStateEnum(int state, int level, int severity, String desc) {
        this.state = state;
        this.level = level;
        this.severity = severity;
        this.desc = desc;
    }

    public static MonitorStateEnum valueOf(Integer state) {
        if (state == null) {
            return null;
        }
        for (MonitorStateEnum stateEnum : MonitorStateEnum.values()) {
            if (stateEnum.state == state) {
                return stateEnum;
            }
        }
        return null;
    }

    public static MonitorStateEnum valueOfLevel(Integer level) {
        if (level == null) {
            return null;
        }
        for (MonitorStateEnum stateEnum : MonitorStateEnum.values()) {
            if (stateEnum.level == level) {
                return stateEnum;
            }
        }
        return null;
    }
}
